﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "制样收样信息";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool">
    <input id="txtBatch" type="text" class="condition-batch" placeholder="批次编码"/>
    <input id="txtStartDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'txtEndDate\')}' })" type="text" class="condition-date" placeholder="收样时间起"/>
    <input id="txtEndDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtStartDate\')}' })" type="text" class="condition-date" placeholder="收样时间止"/>
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnExport", "fa fa-level-up", Resource.Export, ref perm, "Export", true)
</div>
<table id="List"></table>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'BATCH_CODE',
            sortOrder: 'desc',
            idField: 'BATCH_CODE',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            columns: [[
                { field: 'BATCH_CODE', title: '批次编码', width: 80, sortable: true },
                { field: 'SAMPLE_CODE', title: '采样编码', width: 120, sortable: true },
                { field: 'MATERIEL_NAME', title: '物料', width: 80, sortable: true },
                { field: 'MINE_NAME', title: '矿点', width: 80, sortable: true },
                { field: 'SUPPLIER_NAME', title: '供应商', width: 120, sortable: true },
                { field: 'TRANSPORT_NAME', title: '运输商', width: 120, sortable: true },
                { field: 'RFID', title: '样桶RFID', width: 150, sortable: true },
                { field: 'COLLECT_CODE', title: '分样号', width: 120, sortable: true },
                { field: 'WEIGHT', title: '重量', width: 80, sortable: true, hidden: true },
                { field: 'CARCOUNT', title: '车数', width: 60, sortable: true },
                {
                    field: 'SAMPLE_TYPE', title: '样品类型', width: 80, sortable: true,
                    formatter: function (val) {
                        if (val == '1') {
                            return '入炉'
                        } else {
                            return '入厂'
                        }
                    }
                },
                {
                    field: 'WEIGHT_STATUS', title: '称重稳定', width: 80, sortable: true, hidden: true,
                    formatter: function (val) {
                        if (val == '1') {
                            return '不稳定'
                        } else {
                            return '稳定'
                        }
                    }
                },
                { field: 'R_USER_NAME', title: '收样人', width: 60, sortable: true },
                //{ field: 'RECEIVE_TIME', title: '收样时间', width: 120, sortable: true },//20180829吴兵要求去掉
                { field: 'S_USER_NAME', title: '送样人', width: 60, sortable: true },
                
                { field: 'RECEIVE_TIME', title: '收样时间', width: 80, sortable: true },
                {
                    field: 'BLENDED', title: '是否已合样', width: 80, sortable: true, formatter: function (val) {
                        if (val == '1') {
                            return '合样样品'
                        } else {
                            return '原始样'
                        }
                    }
                },
                {
                    field: 'MADE', title: '是否已制样', width: 60, sortable: true, formatter: function (val) {
                        if (val) {
                            return "<img src='@Url.Content("~/image/tick.png")' />";
                        } else {
                            return "<img src='@Url.Content("~/image/bullet_cross.png")' />";
                        }
                    }
                },
            ]]
        });


        if (@Html.FieldShow(ref perm,"IsShow")== 0) {
            $('#List').datagrid('hideColumn', 'MATERIEL_NAME');
            $('#List').datagrid('hideColumn', 'SUPPLIER_NAME');
            $('#List').datagrid('hideColumn', 'TRANSPORT_NAME');
        }
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnQuery").click(function () {

            $("#List").datagrid("load", {
                batch: $("#txtBatch").val(),
                startDate: $("#txtStartDate").val(),
                endDate: $("#txtEndDate").val(),
            });
        });

        $("#btnExport").click(function () {
            var condition = "batch=" + $("#txtBatch").val() +
                        "&startDate=" + $("#txtStartDate").val()+
                        "&endDate=" + $("#txtEndDate").val();
            $.post("@Url.Action("CheckExportData")?" + condition, function (data) {
                if (data.type == 1)
                {
                    window.location = "@Url.Action("Export")?" + condition;
                }
                else
                {
                    $.messageBox5s(Lang.Tip, data.message);
                }
            }, "json");
        });
    });
</script>
